package com.cesgroup.zw.spring.boot.library.echarts.bar.plusOrMinus;

import com.cesgroup.zw.spring.boot.echarts.build.EChartsOption;
import com.cesgroup.zw.spring.boot.echarts.component.*;
import com.cesgroup.zw.spring.boot.echarts.component.axis.XAxis;
import com.cesgroup.zw.spring.boot.echarts.component.axis.YAxis;
import com.cesgroup.zw.spring.boot.echarts.enums.Align;
import com.cesgroup.zw.spring.boot.echarts.enums.AxisPointerType;
import com.cesgroup.zw.spring.boot.echarts.enums.AxisType;
import com.cesgroup.zw.spring.boot.echarts.enums.Trigger;
import com.cesgroup.zw.spring.boot.echarts.model.axis.AxisPointer;
import com.cesgroup.zw.spring.boot.echarts.model.axis.AxisTick;

/**
 * <p>正负柱状图</p>
 * @author ytj
 * @date 2019/7/8 13:12
 */
@SuppressWarnings("serial")
public class PlusOrMinusBarOption extends EChartsOption{
    public PlusOrMinusBarOption(PlusOrMinusBarParam param){
        this.setTitle(new Title(){{
            this.setText("生成监控系统");
            this.setSubtext("实时产能监控");
            this.setLeft(Align.center);
        }});
        this.setTooltip(new Tooltip(){{
            this.setTrigger(Trigger.axis);
            this.setAxisPointer(new AxisPointer(){{
                this.setType(AxisPointerType.shadow);
            }});
            this.setFormatter("function (params) { return params[0].name +'<br>生产中：' + params[0].value +'<br>等待中：' +  -params[1].value; }");
        }});
        this.setLegend(new Legend(){{
            this.setData(param.getDataset().get("type"));
            this.setLeft(Align.right);
        }});
        this.setGrid(new Grid(){{
            this.setLeft("10%");
            this.setRight("4%");
            this.setBottom("3%");
            this.setContainerLabel(true);
        }});
        this.setXAxis(new XAxis(){{
            this.setType(AxisType.value);
        }});
        this.setYAxis(new YAxis(){{
            this.setType(AxisType.category);
            this.setAxisTick(new AxisTick(){{
                this.setShow(false);
            }});
            this.setData(param.getDataset().get("name"));
        }});

    }
}
